import jni.Demo;
import jni.Yolov5OnnxDetector;

import java.io.UnsupportedEncodingException;
import java.net.URL;
import java.net.URLDecoder;

public class JavaDemo {
    public static void main(String[] args) throws UnsupportedEncodingException {
        String ResPath = JavaDemo.class.getClassLoader().getResource("").getPath();//注意getResource("")里面是空字符串
        // 加载DLL文件，加载后native方法自动就有实现了
        System.load(URLDecoder.decode(ResPath+"/opencv_world450.dll", "utf8"));
        System.load(URLDecoder.decode(ResPath+"/onnxruntime.dll", "utf8"));
        System.load(URLDecoder.decode(ResPath+"/CPP2JavaYoloV5Onnx.dll", "utf8"));
        Yolov5OnnxDetector y1 = new Yolov5OnnxDetector();
        y1.InitEnv("W:\\Gitee\\Saves\\1k_6Label_3out_640size.onnx",true,640,640);
        String[] strs = y1.Detect("W:\\Gitee\\Saves\\222.jpg");
        System.out.println(strs.length);
    }
}
